<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/3
 * Time: 10:57
 */
namespace app\index\controller;

use think\Db;
use think\View;
use think\Request;
use think\Controller;
use think\Loader;
use think\Session;

class Supplier  extends Controller
{
    //服务商合作入驻_个人发送验证码 短信息，注册过 通过审核的UN鞥再次注册
    public  function  personalCheckMobile(){
        $sms_code = input('sms_code');
        $phone = input('phone');
        $where1 = array(
            'mobile' => $phone,
            'memberType' => 1,
            'checkStatus' => 1,
        );
        $user = Db::table('member')
            ->alias('a')
            ->join('provider w','a.memberId = w.providerId')
            ->where($where1)
            ->find();
        if($user == null){
            //发送验证码
            $SmsSend = new \app\index\controller\SmsSend();
            $res =  $SmsSend -> index($sms_code,$phone);
        }else{
            $res['code'] = 'fail';
            $res['msg'] = '该手机号已经注册';
        }
        return $res;
    }
    //服务商合作入驻_个人
    public function privider()
    {

            return view('privider');
    }
    //服务商合作入驻_个人
    public function personal()
    {
        if(Request::instance()->method() == 'POST') {
            //验证短信验证码
            $data = $this->request->param();
            //验证用户名，服务商名称
            if(input('memberId')==""){
                $getMemberId=autoId();
                $data['memberId']=autoId();
            }else{
                $getMemberId = input('memberId');
            }
            $memberName = Db::name('member')->where(array('memberName' => input('memberName')))->find();
            $providerName = Db::name('provider')->where(array('providerName' => input('providerName')))->find();
            if($providerName != null){
                if($getMemberId != $providerName['providerId']){
                    $res['type'] = 'providerName';
                    $res['code'] = 'fail';
                    $res['msg'] = '服务商名称已存在';
                    return $res;
                }
            }
            if($memberName != null){
                if($getMemberId != $memberName['memberId']){
                    $res['type'] = 'memberName';
                    $res['code'] = 'fail';
                    $res['msg'] = '用户名已存在';
                    return $res;
                }
            }
            if(input('mobile')){
                $sms_code = input('smsCode');
                $phone = input('mobile');
                //验证码错误返回错误信息
                if($sms_code != Session($phone.'_smsCode')){
                    $res['type'] = 'smsCode';
                    $res['code'] = 'fail';
                    $res['msg'] = '短信验证码错误';
                    return $res;

                }
                //  手机号验证码过期返回错误信息
                $sendTime =  Session($phone.'_sendTime') ;
                $nowTime =  time();
                $sms_code_expire  =    Db::name('param')->where(array('paramCode' => 'VERIFY_CODE_INPUT_LIMIT','isEnable' => '1'))->value('paramValue');
                if($nowTime - $sendTime > ($sms_code_expire * 60)){
                    $res['type'] = 'smsCode';
                    $res['code'] = 'fail';
                    $res['msg'] = '短信验证码超时';
                    Session::delete($phone.'_sendTime');
                    Session::delete($phone.'_smsCode');
                    return  $res;
                }
            }else{
                //查询会员手机号
                $phone =   Db::name('member') ->where(array('memberId'=>Session('Login_userId')))->value('mobile');
                $data['mobile'] = $phone;
            }

            //手机号是否注册为服务商（审核状态不为1）
            $where1 = array(
                'mobile' => $phone,
                'memberType' => 1,
            );
            $user = Db::name('member') ->where($where1)->find();
            Db::startTrans();
            try{
                $member = new \app\index\model\Member();
                //刚打开页面添加提交
                if(input('ciS') == 1){
                    if($user =='' ) {
                        //手机号没有注册为服务商 添加信息
                    }else{
                        //手机号已经注册，删掉之前的数据库信息 ，将 $user设为空''
                        Db::name('member') ->where(array('memberId'=>$user['memberId']))->delete();
                        Db::name('provider') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('provider_guarantee') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('provider_data') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('provider_account') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('provider_group') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('member_account') ->where(array('memberId'=>$user['memberId']))->delete();
                        $user ='' ;
                    }
                }

                //返回上一步修改提交，不用处理
                if(input('ciS') == 2){

                }
                //手机号没有注册为服务商 添加信息
                if($user =='' ) {
                    //添加数据
                    $data['memberId'] = autoId();
                }else{
                    //手机号已经注册为服务商 修改信息
                    $data['memberId']=$user['memberId'];
                }
                $data['providerId'] =  $data['memberId'];
                $data['addDateTime']=date('y-m-d H:i:s',time());;
                //查找推荐人
                if($data['invitationCode'] ==''){
                    $data['inviterId'] =  getProviderId();
                }else{
                    $where2 = array(
                        'invitationCode' =>$data['invitationCode'],
                    );
                    $inviter =  Db::name('member')->where($where2)->cache(false)->find();
                    if($inviter!=''){
                        //找到了推荐人会员ID
                        $data['inviterId'] =   $inviter['memberId'];
                    }else{
                        $data['inviterId'] =   getProviderId();
                    }
                }
                $data['areaId']= $data['districtId'];
                $pgid=$data['serviceCategoryId'];
                $list = [];
                foreach ($pgid as $v){
                    array_push($list,array('providerGroupId'=>autoId(),'providerId'=>$data['providerId'],'provideGroupId'=>$v));
                }
                //插入或更新数据
                //member表的  providerId  保存为 memberId了，应该改改为哪个服务商
                if($user ==''){
                    //审核状态
                    $data['checkStatus']=0;
                    //缴费状态
                    $data['payStatus']=0;
                    //平台连接
                    $data['memberType']=1;
                    $data['providerType']=0;
                    $data['invitationCode'] =   getInvitationCode();
                    $data['providerGuaranteeId'] = autoId();
                    $data['providerLink']=setProviderLink($data['starLevelLink']);;
                    //插入数据
                    $member->allowField(true)->isUpdate(false)->save($data);
                    $provider = new \app\index\model\Provider();
                    $provider->allowField(true)->isUpdate(false)->save($data);
                    $providerGuarantee = new \app\index\model\ProviderGuarantee();
                    $providerGuarantee->allowField(true)->isUpdate(false)->save($data);
                    $providerData = new \app\index\model\ProviderData();
                    $providerData->allowField(true)->isUpdate(false)->save($data);
                    $memberAccount = new \app\index\model\MemberAccount();
                    $memberAccount->allowField(true)->isUpdate(false)->save($data);
                    //结算周期
                    $providerData = new \app\index\model\ProviderAccount();
                    $providerData->allowField(true)->isUpdate(false)->save($data);
                    //联盟
                    $providerGroup = new \app\index\model\ProviderGroup();
                    $providerGroup->saveAll($list, false);
                }else{
                    //更新数据
                    $data['providerLink']=setProviderLink($data['starLevelLink']);;
                    $member->allowField(true)->isUpdate(true)->save($data);
                    $provider = new \app\index\model\Provider();
                    $provider->allowField(true)->isUpdate(true)->save($data);
                    $providerData = new \app\index\model\ProviderData();
                    $providerData->allowField(true)->isUpdate(true)->save($data);
                    $memberAccount = new \app\index\model\MemberAccount();
                    $memberAccount->allowField(true)->isUpdate(true)->save($data);
                    //结算周期
                    $providerData = new \app\index\model\ProviderAccount();
                    $providerData->allowField(true)->isUpdate(true)->save($data);
                    //联盟
                    //删除之前的
                    $providerGroup = new \app\index\model\ProviderGroup();
                    $providerGroup ->where(array('providerId' =>  $data['providerId'] )) ->delete();
                    $providerGroup->allowField(true)->saveAll($list, false);
                }
                //将providerId 更正为 服务商平台；
                $providerId = array(
                    'providerId'=>getProviderId(),
                    'memberId'=>  $data['memberId'],
                    'froms' => 'wap'
                );
                //更新member表
                $member->allowField(true)->isUpdate(true)->save($providerId);
                Db::commit();
                var_dump($data['memberId']);die;
                $res['memberId'] = $data['memberId'].'';
                $res['code'] = 'ok';
                $res['msg'] = '注册成功';
                return $res;
            }catch (\Exception $e) {
                // 回滚事务
                Db::rollback();
                $res['code'] = 'fail';
                $res['msg'] =  $e->getMessage();
                return  $res;
            }
        }else{
            if(input('memberId') ==null){
                //添加信息展示页面
                $area  = getProviderId();
                $ciS = "1";
            }else{
                $ciS = "2";
                $area  = input('memberId');
                //修改信息展示页面
                $where1 = array(
                    'a.memberId' => input('memberId'),
                );
                $user = Db::table('member')
                    ->alias('a')
                    ->join('provider w','a.memberId = w.providerId')
                    ->join('provider_data n','a.memberId = n.providerId')
                    ->join('member_account y','a.memberId = y.memberId')
                    ->where($where1)
                    ->find();
                //查询服务分类
                $user['providerGroup'] = Db::name('provider_group')->where(array('providerId' => input('memberId')))->select();
                if($user['providerGroup'] ==null){
                    $serviceCategory = Db::name('ServiceCategory')->where(array('parentId' => '0'))->find();
                    $user['providerGroup'][0]=array(
                        "provideGroupId"=>$serviceCategory['serviceCategoryId'],
                    );
                }
                //查询邀请码
                if( $user['inviterId'] != 0){
                    $user['inviterCode'] = Db::name('member')->where(array('memberId' => $user['inviterId']))->value('invitationCode');
                }
                //查询头像图片
                $user['headImgFilePath'] = filepath($user['headImgFileId'] );
                //查询身份证图片
                $user['idCardFilePath']  =   filepath($user['idCardFileId'] );
                $user['idCardBackFilePath']  =   filepath($user['idCardBackFileId'] );
                //查询短信验证码 (通过SESSION)
                $user['smsCode'] = Session::get($user['mobile'].'_smsCode');
                $this->view->assign('user', $user);
            }
            //获取三级地区id
            $areaId = DB::name('member')->where('memberId',$area)->value('areaId');
            //获取地级市
            $dId = Db::name('area')->where('areaId',$areaId)->value('parentId');
            //获取省
            $pId = Db::name('area')->where('areaId',$dId)->value('parentId');
            //获取所有省
            $p = Db::name('area')->where('parentId',0)->select();
            //获取当前省下地级市
            $d = Db::name('area')->where('parentId',$pId)->select();
            //获取当前地级市 的县
            $c = Db::name('area')->where('parentId',$dId)->select();
            $v = array(
                'areaId'=>$areaId,
                'dId'   =>$dId,
                'pId'   =>$pId
            );
            $this->view->assign('ciS',$ciS);
            $this->view->assign('city',$v);
            $this->view->assign('p',$p);
            $this->view->assign('c',$c);
            $this->view->assign('d',$d);
            $group1 = Db::name('ServiceCategory')->where(array('parentId' => '0'))->select();
            $this->view->assign('group1', $group1);
            $oi =  Db::name('area')->where(array('parentId' => '0'))->select();
            $this->view->assign('oi', $oi);
            return view('supplierpersonal');
        }
    }
    public function checkStarLevelLink()
    {
        //连表查询
        $where1 =array(
            'starLevelLink'=>input('starLevelLink'),
        );
        //过滤不能用的身份标签
        $canNot  = Db::name('param')->where(array('paramCode' => 'RESERVED_WORD','isEnable' => '1'))->value('paramValue');
        $canNot = explode(',',$canNot);
        if (in_array(input('starLevelLink'),$canNot))
        {
            return false ;
        }
        $provider =   Db::name('provider')->where(array('starLevelLink' => input('starLevelLink')))->find();
        if($provider  == null){
            return 'ok' ;
        }else{
            //是否本人的
            $res  =    Db::name('member')->where(array('memberId' => $provider['providerId']))->find();
            if(input('phone')){
                $phone =   input('phone');
            }else{
                $phone =  Db::name('member')->where(array('memberId' =>Session::get('Login_userId')))->value('mobile');
            }
            if($res['mobile'] == $phone){
                return 'ok' ;
            }
            else{
                return false ;
            }
        }
    }
    public function company()
    {
        if(Request::instance()->method() == 'POST') {
            //验证短信验证码
            $data = $this->request->param();
            //验证用户名，服务商名称
            $getMemberId = input('memberId');
            $memberName = Db::name('member')->where(array('memberName' => input('memberName')))->find();
            $providerName = Db::name('provider')->where(array('providerName' => input('providerName')))->find();
            if($providerName != null){
                if($getMemberId != $providerName['providerId']){
                    $res['type'] = 'providerName';
                    $res['code'] = 'fail';
                    $res['msg'] = '服务商名称已存在';
                    return $res;
                }
            }
            if($memberName != null){
                if($getMemberId != $memberName['memberId']){
                    $res['type'] = 'memberName';
                    $res['code'] = 'fail';
                    $res['msg'] = '用户名已存在';
                    return $res;
                }
            }
            if(input('mobile')){
                $sms_code = input('smsCode');
                $phone = input('mobile');
                //验证码错误返回错误信息
                if($sms_code != Session($phone.'_smsCode')){
                    $res['type'] = 'smsCode';
                    $res['code'] = 'fail';
                    $res['msg'] = '短信验证码错误';
                    return $res;

                }
                //  手机号验证码过期返回错误信息
                $sendTime =  Session($phone.'_sendTime') ;
                $nowTime =  time();
                $sms_code_expire  =    Db::name('param')->where(array('paramCode' => 'VERIFY_CODE_INPUT_LIMIT','isEnable' => '1'))->value('paramValue');
                if($nowTime - $sendTime > ($sms_code_expire * 60)){
                    $res['type'] = 'smsCode';
                    $res['code'] = 'fail';
                    $res['msg'] = '短信验证码超时';
                    Session::delete($phone.'_sendTime');
                    Session::delete($phone.'_smsCode');
                    return  $res;
                }
            }else{
                //查询会员手机号
                $phone =   Db::name('member') ->where(array('memberId'=>Session('Login_userId')))->value('mobile');
                $data['mobile'] = $phone;
            }
            //手机号是否注册为服务商
            $where1 = array(
                'mobile' => $phone,
                'memberType' => 1,
            );
            $user = Db::name('member') ->where($where1)->find();
            Db::startTrans();
            try{
                $member = new \app\index\model\Member();
                if(input('ciS') == 1){
                    if($user =='' ) {
                        //手机号没有注册为服务商 添加信息
                    }else{
                        //手机号已经注册，删掉之前的数据库信息 ，将 $user设为空''
                        Db::name('member') ->where(array('memberId'=>$user['memberId']))->delete();
                        Db::name('provider') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('provider_qualification') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('provider_account') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('provider_group') ->where(array('providerId'=>$user['memberId']))->delete();
                        Db::name('member_account') ->where(array('memberId'=>$user['memberId']))->delete();
                        $user ='' ;
                    }
                }

                //返回上一步修改提交，不用处理
                if(input('ciS') == 2){
                }
                if($user =='') {
                    //手机号没注册为会员
                    $data['memberId'] = autoId();
                }else{
                    //手机号注册为会员
                    $data['memberId']=$user['memberId'];
                }
                $data['providerId'] =  $data['memberId'];
                $data['addDateTime']=date('y-m-d H:i:s',time());;
                //审核状态
                $data['checkStatus']=0;
                //查找推荐人
                if($data['invitationCode'] ==''){
                    $data['inviterId'] =  getProviderId();
                }else{
                    $where2 = array(
                        'invitationCode' =>$data['invitationCode'],
                    );
                    $inviter =  Db::name('member')->where($where2)->cache(false)->find();
                    if($inviter!=''){
                        //找到了推荐人会员ID
                        $data['inviterId'] =   $inviter['memberId'];
                    }else{
                        $data['inviterId'] =  getProviderId();
                    }
                }
                $data['areaId']= $data['districtId'];
                $pgid=$data['serviceCategoryId'];
                $list = [];
                foreach ($pgid as $v){
                    array_push($list,array('providerGroupId'=>autoId(),'providerId'=>$data['providerId'],'provideGroupId'=>$v));
                }
                //插入或更新数据
                //member表的疲软  providerId  保存为 memberId了
                if($user ==''){
                    //插入数据
                    //审核状态
                    $data['checkStatus']=0;
                    //缴费状态
                    $data['payStatus']=0;
                    //平台连接
                    $data['providerLink']=setProviderLink($data['starLevelLink']);;
                    //生成自己的推荐码
                    $data['invitationCode'] =  getInvitationCode();
                    // $invitationCode =   create_code($providerId.$phone);
                    $data['memberType']=1;
                    $data['providerType']=1;
                    $data['payStatus']=0;
                    $data['providerLink']=setProviderLink($data['starLevelLink']);
                    $member->allowField(true)->isUpdate(false)->save($data);
                    $provider = new \app\index\model\Provider();
                    $provider->allowField(true)->isUpdate(false)->save($data);
                    $providerQualification = new \app\index\model\ProviderQualification();
                    $providerQualification->allowField(true)->isUpdate(false)->save($data);
                    $memberAccount = new \app\index\model\MemberAccount();
                    $memberAccount->allowField(true)->isUpdate(false)->save($data);
                    //结算周期
                    $providerData = new \app\index\model\ProviderAccount();
                    $providerData->allowField(true)->isUpdate(false)->save($data);
                    //联盟
                    $providerGroup = new \app\index\model\ProviderGroup();
                    $providerGroup->saveAll($list, false);
                }else{
                    //更新数据
                    $data['providerLink']=setProviderLink($data['starLevelLink']);;
                    $member->allowField(true)->isUpdate(true)->save($data);
                    $provider = new \app\index\model\Provider();
                    $memberAccount = new \app\index\model\MemberAccount();
                    $memberAccount->allowField(true)->isUpdate(true)->save($data);
                    $provider->allowField(true)->isUpdate(true)->save($data);
                    $providerQualification = new \app\index\model\ProviderQualification();
                    $providerQualification->allowField(true)->isUpdate(true)->save($data);
                    //结算周期
                    $providerData = new \app\index\model\ProviderAccount();
                    $providerData->allowField(true)->isUpdate(true)->save($data);
                    //联盟
                    //删除之前的
                    $providerGroup = new \app\index\model\ProviderGroup();
                    $providerGroup ->where(array('providerId' =>  $data['providerId'] )) ->delete();
                    $providerGroup->allowField(true)->saveAll($list, false);
                }
                //将providerId 更正为 0；
                $providerId = array(
                    'providerId'=>getProviderId(),
                    'memberId'=>  $data['memberId'],
                    'froms' => 'wap'
                );
                $member->allowField(true)->isUpdate(true)->save($providerId);
                Db::commit();
                $res['memberId'] = $data['memberId'].'';
                $res['code'] = 'ok';
                $res['msg'] = '注册成功';
                return $res;
            }catch (\Exception $e) {
                // 回滚事务
                Db::rollback();
                $res['code'] = 'fail';
                $res['msg'] =  $e->getMessage();
                return $res;
            }
        }else{
            if(input('memberId') ==null){
                //添加信息展示页面
                //添加信息展示页面
                $area  = getProviderId();
                $ciS = "1";
            }else{
                $ciS = "2";
                $area  = input('memberId');
                //修改信息展示页面
                $where1 = array(
                    'a.memberId' => input('memberId'),
                );
                $user = Db::table('member')
                    ->alias('a')
                    ->join('provider w','a.memberId = w.providerId')
                    ->join('member_account y','a.memberId = y.memberId')
                    ->join('provider_qualification n','a.memberId = n.providerId')
                    ->where($where1)
                    ->find();
                //查询服务分类
                $user['providerGroup'] = Db::name('provider_group')->where(array('providerId' => input('memberId')))->select();
                //查询邀请码
                if( $user['inviterId'] != 0){
                    $user['inviterCode'] = Db::name('member')->where(array('memberId' => $user['inviterId']))->value('invitationCode');
                }
                //查询头像图片
                $user['headImgFilePath'] = filepath($user['headImgFileId'] );
                //查询营业执照
                $user['licenceFilePath']  =   filepath($user['licenceFileId'] );
                //查询短信验证码 (通过SESSION)
                $user['smsCode'] = Session::get($user['mobile'].'_smsCode');
                $this->view->assign('user', $user);
            }
            //获取三级地区id
            $areaId = DB::name('member')->where('memberId',$area)->value('areaId');
            //获取地级市
            $dId = Db::name('area')->where('areaId',$areaId)->value('parentId');
            //获取省
            $pId = Db::name('area')->where('areaId',$dId)->value('parentId');
            //获取所有省
            $p = Db::name('area')->where('parentId',0)->select();
            //获取当前省下地级市
            $d = Db::name('area')->where('parentId',$pId)->select();
            //获取当前地级市 的县
            $c = Db::name('area')->where('parentId',$dId)->select();
            $v = array(
                'areaId'=>$areaId,
                'dId'   =>$dId,
                'pId'   =>$pId
            );
            $this->view->assign('city',$v);
            $this->view->assign('p',$p);
            $this->view->assign('c',$c);
            $this->view->assign('ciS',$ciS);
            $this->view->assign('d',$d);
            $group1 = Db::name('ServiceCategory')->where(array('parentId' => '0'))->select();
            $this->view->assign('group1', $group1);
            $oi =  Db::name('area')->where(array('parentId' => '0'))->select();
            $this->view->assign('oi', $oi);
            return view('suppliercompany');
        }

    }
    public function company1()
    {
        if(Request::instance()->method() == 'POST'){
            //更新数据
            $data = $this->request->param();
            $data['memberId'] = $data['providerId'];
            //查找主键provider_q
            try{
                $memberAccount = new \app\index\model\MemberAccount();
                $memberAccount->allowField(true)->isUpdate(true)->save($data);
                //结算周期
                $providerData = new \app\index\model\ProviderAccount();
                $providerData->allowField(true)->isUpdate(true)->save($data);
                $res['code'] =  'ok';
                $res['memberId'] =  $data['providerId'].'';
                return $res;
            }catch (\Exception $e) {
                // 回滚事务
                Db::rollback();
                $res['code'] = 'fail';
                $res['msg'] =  $e->getMessage();
                return  $res;
            }
        }else{
            $memberId = input('memberId');
            $provider_data =    Db::name('member_account')->where(array('memberId' => $memberId))->find();
            //获取结算周期
            $provider_data['balancePeriod']= Db::name('provider_account')->where(array('providerId' => $memberId))->value('balancePeriod');
            // var_dump($provider_data);die;
            $this->view->assign('memberId', $memberId);
            $this->view->assign('provider_data', $provider_data);
            return view('suppliercompany1');
        }


    }
    public function personal1()
    {
        if(Request::instance()->method() == 'POST'){
            //更新数据
            $data = $this->request->param();
            $data['changeTime'] = date('y-m-d H:i:s',time());;
            $data['providerId'] =  $data['memberId'];
            Db::startTrans();
            try{
                $memberAccount = new \app\index\model\MemberAccount();
                $memberAccount->allowField(true)->isUpdate(true)->save($data);
                //结算周期
                $providerData = new \app\index\model\ProviderAccount();
                $providerData->allowField(true)->isUpdate(true)->save($data);
                $res['code'] =  'ok';
                $res['memberId'] =  $data['providerId'].'';
                return $res;
            }catch (\Exception $e) {
                // 回滚事务
                Db::rollback();
                $res['code'] = 'fail';
                $res['msg'] =  $e->getMessage();
                return  $res;
            }
        }else{
            $memberId = input('memberId');
            $provider_data =    Db::name('member_account')->where(array('memberId' => $memberId))->find();
            //获取结算周期
            $provider_data['balancePeriod']= Db::name('provider_account')->where(array('providerId' => $memberId))->value('balancePeriod');
            // var_dump($provider_data);die;
            $this->view->assign('memberId', $memberId);
            $this->view->assign('provider_data', $provider_data);
            return view('supplierpersonal1');
        }

    }
    public function personal2()
    {
        if(Request::instance()->method() == 'POST'){
            //更新数据
            $data = $this->request->param();
            //查找主键
            $provider_guarantee =     Db::name('provider_guarantee')->where(array('providerId' => $data['providerId']))->value('providerGuaranteeId');
            $data['providerGuaranteeId']  =  $provider_guarantee;
            $providerGuarantee = new \app\index\model\ProviderGuarantee();
            $resule =   $providerGuarantee->allowField(true)->isUpdate(true)->save($data);
            if($resule){
                $res['code'] = 'ok';
                $res['memberId'] = $data['providerId'].'';;
            }else{
                $res['code'] = 'fail';
            }
            return  $res;
        }else{
            $memberId = input('memberId');
            $provider_guarantee =    Db::name('provider_guarantee')->where(array('providerId' => $memberId))->find();
            //查询营业执照
            $provider_guarantee['licenceFilePath'] = filepath($provider_guarantee['licenceFileId'] );
            $this->view->assign('memberId', $memberId);
            $this->view->assign('provider_guarantee', $provider_guarantee);
            return view('supplierpersonal2');
        }

    }
}